package com.zcurd.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	public static String getDateYDMHMS() {
		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
	}

	public static void main(String[] args) {
		System.out.println(getDateYDMHMS());
	}

	public static String dateToString(Date date, String format) {
		if (date == null) {
			return null;
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (StringUtil.isNotEmpty(format)) {
			sdf = new SimpleDateFormat(format);
		}
		String datestr = sdf.format(date);
		return datestr;
	}
}
